package demo.config;
import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.render.ViewType;

import demo.action.*;
import demo.model.User;

public class MyConfig extends JFinalConfig {

	@Override
	public void configConstant(Constants me) {
		me.setDevMode(true);
		me.setViewType(ViewType.JSP);
	}

	@Override
	public void configRoute(Routes me) {
		me.add("/login", TestJFinal.class);
		me.add("/",TestJFinal.class,"/login");
		me.add("/welcome",TestJFinal.class,"/");
		me.add("/tree",TestTree.class,"tree");
		me.add("/flow",FlowController.class,"flow");
		me.add("/testdoc",TestDocController.class,"bizroot/bg");
		me.add("/drawnode",FlowController.class,"flow");
		me.add("/test",TestJFinal.class,"bizroot/test");
	}
	public void systemConfigRoute(Routes me){
		me.add("/login", LoginController.class,"system");
	}
	@Override
	public void configPlugin(Plugins me) {
		loadPropertyFile("jdbc.properties");
		C3p0Plugin c3p0Plugin = new C3p0Plugin(getProperty("jdbcUrl"),
		getProperty("user"), getProperty("password"),getProperty("driver"));
		me.add(c3p0Plugin);
		ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0Plugin);
		me.add(arp);
		arp.addMapping("user","loginid", User.class);
	}

	@Override
	public void configInterceptor(Interceptors me) {}

	@Override
	public void configHandler(Handlers me) {}

}
